﻿using System;

namespace diantou.web.onlineJudge
{
    /// <summary>
    /// 用户相关提交
    /// </summary>
    [fastCSharp.code.cSharp.webView.clientType(Name = "diantou.userJudge")]
    struct userJudge
    {
        /// <summary>
        /// 测试提交
        /// </summary>
        public diantou.dataAccess.judge Judge;
        /// <summary>
        /// 测试提交标识
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        public int Id
        {
            get { return Judge == null ? 0 : Judge.Id; }
        }
        /// <summary>
        /// 用户标识
        /// </summary>
        public int UserId;
        /// <summary>
        /// 是否自己提交
        /// </summary>
        public bool IsSelf
        {
            get { return UserId == Judge.UserId; }
        }
        /// <summary>
        /// 是否赞
        /// </summary>
        public bool IsAgree
        {
            get
            {
                return diantou.dataAccess.tcpCall.focusJudge.IsFocus(UserId, Judge.Id, dataModel.focus.type.Agree);
            }
        }
        /// <summary>
        /// 是否管理员用户
        /// </summary>
        public bool IsAdmin;
        /// <summary>
        /// 提交得分
        /// </summary>
        public int Point;
        /// <summary>
        /// 是否可以查看测试代码
        /// </summary>
        public bool IsProgramContent
        {
            get
            {
                if (UserId == Judge.UserId || IsAdmin) return true;
                return Judge.Result == OnlineJudge.JudgeResult.Accepted &&
                    diantou.dataAccess.tcpCall.judge.isProgramContent(Judge.Id, UserId);
            }
        }
        /// <summary>
        /// 是否可以查看编译错误
        /// </summary>
        public bool IsCompileError
        {
            get
            {
                return Judge.State == diantou.dataModel.judgeState.state.CompileError && (UserId == Judge.UserId || IsAdmin);
            }
        }
    }
}
